<template>
  <div>
    <mt-header title="我的账户" fixed style="background-color: #24aa7d;color:#fff;">
      <router-link to="/me" slot="left">
        <mt-button icon="back"></mt-button>
      </router-link>
    </mt-header>
    <div style="height:8rem">
      <p class="title_name">我的余额</p>
      <p class="money">{{money}}元</p>
    </div>
    <div class="kong"></div>
    <mt-cell style="height:2rem;border-bottom:1px solid #eee" to="/detailed" title="账户明细">
      <i class="iconfont iconyou"></i>
      <!-- <img slot="icon" src="../../assets/images/home.png" width="24" height="24" /> -->
      <i class="iconfont iconzuomingxi icon"></i>
    </mt-cell>
    <mt-button
      style="background:red;margin-top:3rem"
      class="btn"
      @click="btn_account"
      type="primary"
    >充值</mt-button>
  </div>
</template>

<script>
import https from "../../utils/http.js";
export default {
  props: {},
  data() {
    return {
      wx_value: [],
      // token:''
      token: "002000AB008C004C004800D700C60082006700CD00E6000300E0005700B100F4",
      money: 0
    };
  },
  computed: {},
  created() {
    this.token = localStorage.getItem("token");
  },
  mounted() {
    this.get_account();
  },
  watch: {},
  methods: {
    btn_account() {
      this.$router.push("/recharge");
      // https({
      //   method: "post",
      //   url: "/api/WxPay/PubPay",
      //   data: {
      //     TokenCode:this.token,
      //     VersionCode: "1.0",
      //     TimeStamp: 0,
      //     FormData: {},
      //     RecordKey: 2,
      //     SignCode: ""
      //   }
      // })
      //   .then(res => {
      //     this.wx_value = JSON.parse(res.ResultValue);
      //     console.log(this.wx_value);
      //     WeixinJSBridge.invoke(
      //       "getBrandWCPayRequest",
      //       {
      //         appId: this.wx_value.appId, //公众号名称，由商户传入
      //         timeStamp: this.wx_value.timeStamp, //时间戳，自1970年以来的秒数
      //         nonceStr: this.wx_value.nonceStr, //随机串
      //         package: this.wx_value.package,
      //         signType: this.wx_value.signType, //微信签名方式：
      //         paySign: this.wx_value.paySign //微信签名
      //       },
      //       function(res) {
      //         console.log(res);
      //         // if (res.err_msg == "get_brand_wcpay_request:ok") {

      //         // }
      //       }
      //     );
      //   })
      //   .catch(err => {
      //     console.log(err);
      //   });
    },
    get_account() {
      https({
        method: "post",
        url: "/api/Members/GetBalance",
        data: {
          TokenCode: this.token,
          VersionCode: "1.0",
          TimeStamp: 0,
          FormData: {},
          RecordKey: "",
          SignCode: ""
        }
      })
        .then(res => {
          if (res.ResultCode == 111111) {
            this.money = res.ResultValue;
          }
        })
        .catch(err => {
          console.log(err);
        });
    }
  },
  components: {}
};
</script>

<style scoped lang="less">
.title_name {
  width: 98%;
  height: 40px;
  line-height: 40px;
  padding-left: 5%;
  padding-top: 2rem;
  font-size: 1.2rem;
  box-sizing: border-box;
}
.money {
  margin-top: 1.6rem;
  width: 98%;

  line-height: 40px;
  padding-left: 5%;
  padding-top: 1.5rem;
  font-size: 1.6rem;
  font-weight: 800;
  color: red;
  box-sizing: border-box;
}
.iconfont {
  font-size: 1rem;
}
.icon {
  position: absolute;
  left: 1rem;
  top: 1rem;
  font-size: 1.2rem;
  color: #24aa7d;
}

.kong {
  width: 100%;
  height: 10px;
  background: #eee;
  margin-bottom: 1rem;
}
.btn {
  width: 80%;
  height: 80px;
  margin-left: 10%;
  margin-top: 20px;
  background: #24aa7d;
}
</style>
